package com.hongkuncheng.cms.model;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;
import java.io.Serializable;

@Entity
public class Gather implements Serializable {
    protected int id;
    protected String name;
    protected String targeturl;
    protected String encode;
    protected String regexlist;
    protected String regexlinkurl;
    protected String regexdetail;
    protected boolean outlink;
    protected boolean autogather;
    private List<GatherReColumns> gatherReColumnses;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name", nullable = false, length = 255)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "targeturl", nullable = false, length = 255)
    public String getTargeturl() {
        return targeturl;
    }

    public void setTargeturl(String targeturl) {
        this.targeturl = targeturl;
    }

    @Basic
    @Column(name = "encode", nullable = false, length = 255)
    public String getEncode() {
        return encode;
    }

    public void setEncode(String encode) {
        this.encode = encode;
    }

    @Basic
    @Column(name = "regexlist", nullable = false, length = -1)
    public String getRegexlist() {
        return regexlist;
    }

    public void setRegexlist(String regexlist) {
        this.regexlist = regexlist;
    }

    @Basic
    @Column(name = "regexlinkurl", nullable = false, length = -1)
    public String getRegexlinkurl() {
        return regexlinkurl;
    }

    public void setRegexlinkurl(String regexlinkurl) {
        this.regexlinkurl = regexlinkurl;
    }

    @Basic
    @Column(name = "regexdetail", nullable = false, length = -1)
    public String getRegexdetail() {
        return regexdetail;
    }

    public void setRegexdetail(String regexdetail) {
        this.regexdetail = regexdetail;
    }

    @Basic
    @Column(name = "outlink", nullable = false)
    public boolean isOutlink() {
        return outlink;
    }

    public void setOutlink(boolean outlink) {
        this.outlink = outlink;
    }

    @Basic
    @Column(name = "autogather", nullable = false)
    public boolean isAutogather() {
        return autogather;
    }

    public void setAutogather(boolean autogather) {
        this.autogather = autogather;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Gather gather = (Gather) o;
        return id == gather.id &&
                outlink == gather.outlink &&
                autogather == gather.autogather &&
                Objects.equals(name, gather.name) &&
                Objects.equals(targeturl, gather.targeturl) &&
                Objects.equals(encode, gather.encode) &&
                Objects.equals(regexlist, gather.regexlist) &&
                Objects.equals(regexlinkurl, gather.regexlinkurl) &&
                Objects.equals(regexdetail, gather.regexdetail);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, targeturl, encode, regexlist, regexlinkurl, regexdetail, outlink, autogather);
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "gather")
    public List<GatherReColumns> getGatherReColumnses() {
        return gatherReColumnses;
    }

    public void setGatherReColumnses(List<GatherReColumns> gatherReColumnses) {
        this.gatherReColumnses = gatherReColumnses;
    }
}
